<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <script src="../../js/mui.min.js"></script>
    <script type="text/javascript" src="../../js/common.js"></script>
    <link href="../../css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="../../css/own.css"/>
    <script type="text/javascript" charset="UTF-8">
      	mui.init({
			pullRefresh: {      
			    container: "#pullrefresh",//待刷新区域标识
			    up : {
			      contentrefresh: "正在加载...",//可选，正在加载状态时，上拉加载控件上显示的标题内容
			      callback: fundmore, //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
			    }
			 } 
		});
		   
		  var list=null;  
		  var list_num=0;  
		  mui.plusReady(function(){   
		  	//初始化监听头部和底部事件
  			var paramUrl={
				url:"../login/login.html"
			}
			
		  	//获取资金明细信息
		  	mui.app_request("/user/fund/list",{},function(result){
		  		if(!mui.isnull(result.data)){
		  			var income="收入"+result.data.incomeNum+"笔："+tzdr.moneyUtils.decimal(result.data.incomeMoney,2)+"元";
		  			var out="支出"+result.data.outlayNum+"笔："+tzdr.moneyUtils.decimal(result.data.outlayMoney,2)+"元";
		  			
		  			document.getElementById("left").innerHTML=income;
		  			document.getElementById("right").innerHTML=out;
		  			list=result.data.fundList;  
		  			
		  			if(!mui.isnull(list)){
							   
		  				mui.each(list,function(i,item){
		  				if(i<10){
		  					
		  					fundList(item);
		  					list_num++;
		  					
		  				}  
		  			}); 
		  			}
		  			
		  		}
		  		
		  	},function(result){
		  		mui.toast(result.message);
		  		return;
		  	},paramUrl);

			
		  });
		  
		  
		  //加载更多  
		  function fundmore(){
		  	
		  	if(!mui.isnull(list)&&list.length>10){
		  		
		  		var isnum=(list.length-(list_num+10)) >=0 ? true : false;
		  		
		  		if(isnum){
		  			 
		  			//每次加载十条
			  		for(var i=0;i<10;i++){
			  			fundList(list[list_num]);  
			  			list_num++;
			  			
			  		}
			  		mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
		  		}else{
		  			var obj_num=list.length-list_num;
		  			//最后不足十条
			  		for(var i=0;i<obj_num;i++){
			  			fundList(list[list_num]);
			  			list_num++;
			  			
			  		}
			  		
			  		mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
			  		
		  		}
		  		
		  		
		  	}else{
		  		mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
		  	}
		  }
		  
		  function fundList(fund){
		  	var $fundList=document.body.querySelector(".mui-table-view"); 
		  	
		  	var li=document.createElement("li");
		  	
		  	var iscome=fund.money >= 0 ? true : false; 
		  	var p1=document.createElement("p");
		  	p1.setAttribute("class","af_time");
		  	
		  	var b1=document.createElement("b");
		  	var timeo=tzdr.dateUtil.getFormatDataByLong(fund.payTime,"yyyy-MM-dd");
		  	var timet=tzdr.dateUtil.getFormatDataByLong(fund.payTime,"hh:mm");
		  	p1.innerHTML=timeo;
		  	b1.innerHTML=timet;
		  	var p2=document.createElement("p");
		  	p2.setAttribute("class","af_date");
		  	
		  	
		  	if(iscome){
		  		li.setAttribute("class","mui-table-view-cell af_income");
		  		p2.innerHTML="+"+fund.money+"元";
		  	}else{
		  		li.setAttribute("class","mui-table-view-cell af_exp");
		  		p2.innerHTML=fund.money+"元"; 
		  	}
		  	var b2=document.createElement("b");
		  	b2.innerHTML=fund.remark;
		  	
		  	p1.appendChild(b1);
		  	p2.appendChild(b2);
		  	li.appendChild(p1);
		  	li.appendChild(p2);
		  	
		  	$fundList.appendChild(li);
		  }
		  
    </script>
</head>
<body>
	<!--<nav class="navlist">
		<a href="javascript:void(0);" id="product">
			<span class="mui-icon mui-icon-list"></span>
			<span class="mui-tab-label">产品</span>
		</a>
		<a class="" href="javascript:void(0);"  id="scheme">
			<span class="mui-icon mui-icon-compose"></span>
			<span class="mui-tab-label">方案</span>
		</a>
		<a  class="navon"  id="account" href="javascript:void(0);">
			<span class="mui-icon mui-icon-contact mui-icon-icon-contact-filled"></span>
			<span class="mui-tab-label" >账户</span>
		</a>
	</nav>-->
	<!--下拉刷新容器-->
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper ac_tel" style="padding-top:0;">
			
			<div class="mui-scroll af_list">
				<div class="af_total">
					<span id="left" class="left">收入0笔： 0.00元</span>
					<span id="right" class="right">支出0笔： 0.00元</span>
				</div>
				<!--数据列表-->
				<ul class="mui-table-view af_list"  id="fundListul">
					
				</ul>
			</div>
		</div>
	
</body>
</html>